﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class netpayclient_order_feedback : System.Web.UI.Page 
{
    public static string flag = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        string MerId = Request["MerId"];//商户号
        string OrdId = Request["OrderNo"];//订单号
        string TransAmt = Request["Amount"];//订单金额
        string CuryId = Request["CurrencyCode"];//货币代码
        string TransDate = Request["TransDate"];//订单日期
        string TransType = Request["TransType"];//交易类型
        string Priv1 = Request["Priv1"];//备注
        string GateId = Request["GateId"];//网关
        string status = Request["status"];
       
        string CheckValue = Request["checkvalue"];//签名数据   
        bool res = SignData.check(MerId, OrdId, TransAmt, CuryId, TransDate, TransType, status, CheckValue);
        if (res){
            flag = "0";
            //在数据库中记录缴费信息
            //判断处理后的订单号与提交的订单号是否一致
            string userName = Session["userName"].ToString();
            string password = Session["password"].ToString();

            string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("./App_Data/paymentInfo.mdb");//创建OleDbConnection对象 
            System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection(ConStr);
            con.Open();

            if (con.State == System.Data.ConnectionState.Open)
            {
                System.Data.OleDb.OleDbCommand cmd1 = new System.Data.OleDb.OleDbCommand("update record set orderid=@orderid, orderdate=@orderdate, result=1 where username=@userName and password=@password", con);
                cmd1.Parameters.Add("@orderid", OrdId);
                cmd1.Parameters.Add("@orderdate", TransDate);
                cmd1.Parameters.Add("@userName", userName);
                cmd1.Parameters.Add("@password", password);
                int count = cmd1.ExecuteNonQuery();

                if (1 == count)
                {
                    Session["result"] = "1";
                    Response.Redirect("paymentInfo.aspx");
                }
            }
            con.Close();
        }else{
            flag = "1";
        }

    }
}
